﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using TDT_Project.classes;
using Telerik.Web.UI;
namespace TDT_Project.Controller
{
    public partial class UC_GV_GIANGDAY : System.Web.UI.UserControl
    {
        cls_phuhuynhxemdiem cls = new cls_phuhuynhxemdiem();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                if (Session["nk"] != null)
                {
                    DataTable dt = new DataTable();
                    DataSet ds = cls.Get_gv_day("HK1", Session["nk"].ToString(), Session["lop"].ToString());
                    if (ds != null && ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            gvResult_TTT.DataSource = ds.Tables[0].DefaultView;
                            gvResult_TTT.DataBind();
                        }
                        else
                        {
                            gvResult_TTT.DataSource = dt;
                            gvResult_TTT.DataBind();
                        }
                    else
                    {
                        gvResult_TTT.DataSource = dt;
                        gvResult_TTT.DataBind();
                    }
                }
                else
                    Response.Redirect("Default.aspx");
            }
        }

        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Session["nk"] != null)
            {
                DataTable dt = new DataTable();
                string hk = "HK1";
                if (RadioButtonList1.SelectedValue.ToString() == "HK2")
                    hk = "HK2";
                DataSet ds = cls.Get_gv_day(hk, Session["nk"].ToString(), Session["lop"].ToString());
                if (ds != null && ds.Tables.Count > 0)
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        gvResult_TTT.DataSource = ds.Tables[0].DefaultView;
                        gvResult_TTT.DataBind();
                    }
                    else
                    {
                        gvResult_TTT.DataSource = dt;
                        gvResult_TTT.DataBind();
                    }
                else
                {
                    gvResult_TTT.DataSource = dt;
                    gvResult_TTT.DataBind();
                }
            }
            else
                Response.Redirect("Default.aspx");
        }
    }
}